//AC both small data and large data
#include<stdio.h>

#define FILEIO 1

int n;//number of case
int m;//numbers per line
int a[1000];
int b[1000];
int i,j,k;//for loop

void exchange(int *a,int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}


int Partition(int a[],int p,int r)
{
	int x = a[r];
	int i = p-1;
	int j = p;
	for(;j<=r-1;j++)
	{
		if(a[j]<x)
		{
			i+=1;
			exchange(&a[i],&a[j]);
		}
	}
	exchange(&a[i+1],&a[r]);
	return i+1;
}

void QuickSort(int a[],int p,int r)
{
	int q;
	if (p<r)
	{
		q = Partition(a,p,r);
		QuickSort(a,p,q-1);
		QuickSort(a,q+1,r);
	}
}

void XMEMSET()
{
	int i=0;
	for(i=0;i<1000;i++)
	{
		a[i]=0;
		b[i]=0;
	}
}

int main() 
{ 
#ifdef FILEIO
  freopen("in.txt","r",stdin); 
  freopen("out.txt","w",stdout); 
#endif

  scanf("%d",&n);
  for(k=0;k<n;k++)
  {
	  scanf("%d",&m);
	  for(j=0;j<m;j++)
	  {
		  scanf("%d",&a[j]);
	  }
	  QuickSort(a,0,m-1);
	  for(j=0;j<m;j++)
	  {
		  scanf("%d",&b[j]);
	  }
	  QuickSort(b,0,m-1);

	  long long sum=0;

	  for(j=0;j<m;j++)
	  {
		  sum+=(long long)a[j]*(long long)b[m-1-j];
	  }

	  printf("Case #%d: %lld\n",k+1,sum);
#ifdef OUTPUT
	  for(j=0;j<m;j++)
	  {
		  printf("%d ",a[j]);
	  }
	  printf("\n");
	  for(j=0;j<m;j++)
	  {
		  printf("%d ",b[j]);
	  }
	  printf("\n");
#endif
  }


#ifdef FILEIO
  fclose(stdin);
  fclose(stdout);
#endif  
  
  return 0; 
}
